@for $i from 0 through 50 {
    [line-h#{$i}], .line-h#{$i} {
        line-height: #{$i}px;
    }
}

$direction: (l left, r right, t top, b bottom);
@for $i from 0 through 50 {
    @each $type in m, p, v, h, a {
        @if $type == m {
            @each $d in $direction {
                [m#{nth($d, 1)}#{$i}], .m#{nth($d, 1)}#{$i} {
                    margin-#{nth($d, 2)}: #{$i}px;
                }
            }
        } @else if $type == p {
            @each $d in $direction {
                [p#{nth($d, 1)}#{$i}], .p#{nth($d, 1)}#{$i} {
                    padding-#{nth($d, 2)}: #{$i}px;
                }
            }
        } @else if $type == h {
            [ph#{$i}], .ph#{$i} {
                padding-left: #{$i}px;
                padding-right: #{$i}px;
            }
            [mh#{$i}], .mh#{$i} {
                margin-left: #{$i}px;
                margin-right: #{$i}px;
            }
        } @else if $type == v {
            [pv#{$i}], .pv#{$i} {
                padding-top: #{$i}px;
                padding-bottom: #{$i}px;
            }
        } @else {
            [pa#{$i}], .pa#{$i} {
                padding: #{$i}px;
            }
        }
    }
}